|
In computer programming, a function prototype or function interface is a declaration of a function that specifies the function's name and type signature (arity, parameter types, and return type), but omits the function body. The term is particularly used in C and C++. While a function definition specifies ''how'' the function does what it does (the "implementation"), a function prototype merely specifies its interface, i.e. ''what'' data types go in and come out of it. In a prototype, parameter names are optional (and in C/C++ have function prototype scope, meaning their scope ends at the end of the prototype), however, the type is necessary along with all modifiers (e.g. if it is a pointer or a const parameter). In object-oriented programming, interfaces and abstract methods serve much the same purpose. == Example == Consider the following function prototypes: This prototype specifies that in this program, there is a function named "myfunction" which takes a single integer argument "n" and returns an integer. Elsewhere in the program a function definition must be provided if one wishes to use this function. It's important to be aware that a declaration of a function does not need to include any arguments. The following is an argument-less function declaration, which just declares the function name and its return type, but doesn't tell what parameter types the definition expects. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Function prototype」の詳細全文を読む スポンサード リンク
|